package com.yuyang.wifi.utils;

import android.content.Context;
import android.os.Environment;

import java.io.File;

/**
 * Created by liting on 17/2/17.
 */

public class PathUtils {

    public static String getFileStorePath(Context context) {
        String path = "";

        if (isSDCardMounted()) {
            //path = Environment.getExternalStorageDirectory() + "/huluz/";
            //LogUtils.e("kkk", path);
            //path = Environment.getExternalStoragePublicDirectory(null) + "/partof/";
            //LogUtils.e("kkk", path);
            path = context.getExternalFilesDir(null) + "/huluz/";
            //LogUtils.e("kkk", path);
        } else {
            path = context.getCacheDir() + "/huluz/";
        }
        create(path);
        return path;
    }

    public static String getApkPath(Context context) {
        String path = getFileStorePath(context) + "apk/";
        create(path);
        return path;
    }

    public static String getCamaraPath(Context context) {
        String path = getFileStorePath(context) + "camara/";
        create(path);
        return path;
    }

    public static String getCropPath(Context context) {
        String path = getFileStorePath(context) + "crop/";
        create(path);
        return path;
    }

    public static String getScalePath(Context context) {
        String path = getFileStorePath(context) + "scale/";
        create(path);
        return path;
    }

    public static String getCacheSmallPath(Context context) {
        String path = getFileStorePath(context) + "cachesmall/";
        create(path);
        return path;
    }

    public static String getCachePath(Context context) {
        String path = getFileStorePath(context) + "cache/";
        create(path);
        return path;
    }

    public static String getApkCash(Context context) {
        String path = getFileStorePath(context) + "cashInfo/";
        create(path);
        return path;
    }

    public static String getApkCashData(Context context) {
        String path = getFileStorePath(context) + "cashInfoData/";
        create(path);
        return path;
    }

    private static boolean isSDCardMounted() {
        boolean isSDCard = false;
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            isSDCard = true;
        }
        return isSDCard;
    }

    private static void create(String path) {
        File folderDir = new File(path);
        if (!folderDir.exists() && folderDir.mkdirs()) {

        }
    }
}
